<template>
    <!--人才储备-->
  <div  >
    <div>
      <div class="header">
        人才储备
      </div>
      <div class="EchartBox">
        <div id="back" ></div>
      </div>

    </div>
  </div>

</template>

<script>
import axios from "axios";

import { mapState } from "vuex";

export default {
  name: "Person",
  data(){
    return{
      datas:[
        { value: 64, name: "男" },
        { value: 32, name: "女" },
        { value: 12, name: "未知" },
      ],
    }
  },
  computed:{
    ...mapState(['setdatas'])
  },
  methods:{
    //数据对接

    getPersons(){
      const myChart = this.$echarts.init(document.getElementById("back"))//引入到盒子
      const option = {
        title: {
          text: '人才数据库统计',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '人才储备',
            type: 'pie',
            radius: '50%',
            data: this.setdatas,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);

    },
    getPersonData(){

     // let {data:res} = await axios.get('http://132.232.110.185/personnelManagement/dataStatistics/talentReserveStatistics')
      axios({
        url: 'http://132.232.110.185/personnelManagement/dataStatistics/talentReserveStatistics',
        method: 'get',

      }).then((response) => {

        this.$store.dispatch('setdatas',response.data.data)



      })

    },

  },
  mounted() {
    this.getPersons()
    this.getPersonData()
  }
}
</script>

<style scoped>
.header{
  width: 100%;
  height: 74px;
  border-bottom: 1px solid rgba(0,0,0,0.3);
  padding-left:12px ;
  line-height: 74px;
  font-size: 18px;
}

.EchartBox{
  border: 1px solid;
  height: 700px;
  width: 100%;
}
#back{
  width: 100%;
  text-align: center;
  height: 700px;
  line-height: 700px;
  margin:22px auto 0;

}



</style>


